home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / include / scribus-ng / chartablemodel.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-10-08  |  3.1 KB  |  102 lines

  1. /*
  2. For general Scribus (>=1.3.2) copyright and licensing information please refer
  3. to the COPYING file provided with the program. Following this notice may exist
  4. a copyright and/or license notice that predates the release of Scribus 1.3.2
  5. for which a new license (GPL+exception) is in place.
  6. */
  7. #ifndef CHARTABLEMODEL_H
  8. #define CHARTABLEMODEL_H
  9.  
  10. #include <QAbstractTableModel>
  11.  
  12. #include "scribusapi.h"
  13.  
  14. class ScribusDoc;
  15. class ScFace;
  16. class QItemSelectionModel;
  17.  
  18.  
  19. //! \brief A special type for character classes
  20. typedef QList<uint> CharClassDef;
  21.  
  22.  
  23. /*! \brief A model (MVC) to handle unicode characters map.
  24. It's a backend for CharTableView - its GUI representation.
  25. \warning: CharTableModel and CharTableView are designed for 1:1 relations!
  26. \author Petr Vanek <petr@scribus.info>
  27. */
  28. class SCRIBUS_API CharTableModel : public QAbstractTableModel
  29. {
  30.     Q_OBJECT
  31.  
  32. public:
  33.     CharTableModel(QObject *parent = 0, int cols = 4, ScribusDoc * doc = 0, const QString & font = 0);
  34.  
  35.     int rowCount(const QModelIndex &parent = QModelIndex()) const;
  36.     int columnCount(const QModelIndex &parent = QModelIndex()) const;
  37.  
  38.     //! \brief Get a graphics representation/pixmap of the glyph
  39.     QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
  40.  
  41.     void setFontInUse(QString font);
  42.  
  43.     //! \brief Font in use. It's used in model's view.
  44.     ScFace fontFace();
  45.  
  46.     void setCharacters(CharClassDef ch);
  47.     CharClassDef characters() {
  48.         return m_characters;
  49.     };
  50.  
  51.     //! \brief called to erase glyph at index from table.
  52.     bool removeCharacter(int index);
  53.  
  54.     void setDoc(ScribusDoc *doc);
  55.  
  56.     void setViewWidth(int w) {
  57.         m_viewWidth = w;
  58.     };
  59.  
  60. public slots:
  61.     /*! \brief appends an unicode char into m_characters list.
  62.     \param s a QString with numerical representation of the character.
  63.     \param base an optional parameter containing base of the numerical converion. See QString::toInt() documentation.
  64.     The base parameter is used mainly in normal code - not in slot calls.
  65.     If user adds an already existing glyph it's rejected and the original
  66.     one is selected (see selectionChanged()).
  67.     */
  68.     void appendUnicode(const QString & s, uint base = 16);
  69.  
  70. signals:
  71.     /*! \brief Inform its view about internal selection changes.
  72.     It's emitted everytime user adds an existing glyph to the
  73.     CharClassDef list. */
  74.     void selectionChanged(QItemSelectionModel * model);
  75.     //! \brief Emitted when there is a new row
  76.     void rowAppended();
  77.  
  78. private:
  79.     ScribusDoc *m_doc;
  80.     //! \brief Number of the columns for model
  81.     int m_cols;
  82.     //! \brief View's width to compute pixmap sizes.
  83.     int m_viewWidth;
  84.  
  85.     QString m_fontInUse;
  86.     CharClassDef m_characters;
  87.  
  88.     //! \brief Internal selection handling. See selectionChanged().
  89.     QItemSelectionModel * m_selectionModel;
  90.  
  91.     /*! \brief All drag'n'drop actions are handled in this model only
  92.     See Qt4 docs "Using Drag and Drop with Item Views" for more info.
  93.     */
  94.     Qt::ItemFlags flags(const QModelIndex &index) const;
  95.     Qt::DropActions supportedDropActions() const;
  96.     QStringList mimeTypes() const;
  97.     QMimeData * mimeData(const QModelIndexList &indexes) const;
  98.     bool dropMimeData(const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent);
  99. };
  100.  
  101. #endif
  102.